package com.jimmyhsu.ecnudaowei.Bean;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * Created by jimmyhsu on 2017/3/8.
 */
public class TaskActivity {

    public static final String TB_COURSE = "coursetb";
    public static final String COL_COURSE_ID = "col_course_id";
    public static final String COL_COURSE_NAME = "col_course_name";
    public static final String COL_TEACHER = "col_teacher";
    public static final String COL_LOCATION = "col_location";
    public static final String COL_COURSE_WEEK = "col_course_week";
    public static final String COL_DURATION = "col_duration";
    public static final String COL_DAY = "col_day";
    public static final String COL_NUMBER = "col_number";
    public static final String COL_ADD_BY_USER = "col_add_by_user";

    private int _id;
    @Expose
    @SerializedName("course_id")
    private String courseId;
    @Expose
    @SerializedName("course_name")
    private String courseName;
    @Expose
    private String teacher;
    @Expose
    private String location;
    @Expose
    @SerializedName("week")
    private String courseWeek;
    @Expose
    private int duration;
    private boolean addByUser;
    @Expose
    private int day;
    @Expose
    private int number;


    public TaskActivity(String courseId, String courseName, String teacher, String location,
                        String courseWeek, int day, int number, boolean addByUser) {
        this.courseId = courseId;
        this.courseName = courseName;
        this.teacher = teacher;
        this.location = location;
        this.courseWeek = courseWeek;
        this.duration = 1;
        this.day = day;
        this.number = number;
        this.addByUser = addByUser;
    }

    public TaskActivity(int _id, String courseId, String courseName, String teacher, String location,
                        String courseWeek, int day, int number, boolean addByUser) {
        this._id = _id;
        this.courseId = courseId;
        this.courseName = courseName;
        this.teacher = teacher;
        this.location = location;
        this.courseWeek = courseWeek;
        this.duration = 1;
        this.day = day;
        this.number = number;
        this.addByUser = addByUser;
    }

    public boolean isAddByUser() {
        return addByUser;
    }

    public void setAddByUser(boolean addByUser) {
        this.addByUser = addByUser;
    }

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public boolean haveLessonAt(int weekNo) {
        return courseWeek.charAt(weekNo+1) == '1';
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public String getCourseId() {
        return courseId;
    }

    public void setCourseId(String courseId) {
        this.courseId = courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getTeacher() {
        return teacher;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getCourseWeek() {
        return courseWeek;
    }

    public void setCourseWeek(String courseWeek) {
        this.courseWeek = courseWeek;
    }

    public boolean isAdjacent(TaskActivity another, int weekday, int classNumber) {
        return courseId.equals(another.courseId) &&
                day == weekday &&
                Math.abs(number - classNumber) == 1 &&
                courseWeek.equals(another.courseWeek);
    }
}
